<%@ page contentType="text/html;charset=utf-8"%>
<%@ page import="java.util.*"%>
<%
Map queryMap = (HashMap)request.getAttribute("queryMap");
List<Map> articleTypeMap = (List<Map>) request.getAttribute("articleTypeMap");
List<Map> lt = (List)request.getAttribute("list");
%>
<div class="content-box">
				<div class="content-box-header">
					<h3>文章搜索条件</h3>
					<div class="clear"></div>
				</div> 
                <div class="content-box-content">
                <form name="searchForm" method="post">
               	   <table>
               	   	<thead>
						   <tr style="padding: 4px">
		                   	   <td style="width:100px;text-align:right">文章类型:&nbsp;</td>
		                       <td style="width:150px"><select name="article_type">
		                        	<option value="">所有</option>
									<%
										if(articleTypeMap.size()>0){
										for (int t = 0; t < articleTypeMap.size(); t++) {
									%>
									<option <%= queryMap!=null?(queryMap.get("article_type")!=null?(queryMap.get("article_type").equals(articleTypeMap.get(t).get("article_type_id"))?"selected":""):""):""  %> value="<%=articleTypeMap.get(t).get("article_type_id")%>"><%=articleTypeMap.get(t).get("article_type_name")%></option>
									<%
										}}
									%>
								</select></td>
		                       <td style="width:100px;text-align:right">文章标题:&nbsp;</td>
		                       <td style="width:150px"><input type="text" name="article_name" value="${queryMap.article_name}" size="24" maxlength="24"/></td>
		                   </tr>
		                    <tr>
		                   		<td colspan="4">&nbsp;</td>
		                   </tr>
		                   <tr style="padding: 4px">
		                       <td style="width:100px;text-align:right">关联游戏:&nbsp;</td>
		                       <td style="width:150px"><input type="text" name="game_id" value="${queryMap.game_id}" size="24" maxlength="24"/></td>
		                       <td style="width:100px;text-align:right">创建日期:&nbsp;</td>
		                       <td style="width:150px"><input type="text" name="article_create_date" value="${queryMap.article_create_date}" size="24" onclick="JTC.setday(this)" readonly maxlength="24" size="24" maxlength="24"/></td>
		                   </tr>
		                   
		                   <tr>
		                   		<td colspan="4">
		                   			<!-- 分页条件START -->
									<input name="CurrentPage"  id="CurrentPage" style="display: none" value="" />
									<!-- 分页条件END -->
								</td>
		                   </tr>
		                   <tr>
		                  	   <td colspan="3"></td>
		                  	   <td style="text-align: right"><input style="border:solid 1px #000;width:160px;cursor:pointer;height:40px;margin-top:8px" onmousemove=(this.style.background='#57a000') onmouseout=(this.style.background='#FFF') onclick="toSearch()" type="button" value="查询"/></td>
		                   </tr>
		             </thead>
                   </table>
                   </form>
                </div>
</div>
<div class="content-box">
<script type="text/javascript" src="/resources/scripts/JTimer.js"></script>
<script>
//查询
function toSearch(){
	var searchForm = document.getElementsByName("searchForm")[0];
	searchForm.action="articleManage.do?pm=gotoArticleList";
	searchForm.submit();
}

//修改
function toModify(obj){
var modifyId=$(obj).parent().parent().find("input[type=checkbox]").attr("id");
		location.href="articleManage.do?pm=gotoArticleModify&id="+modifyId;
}
//删除
function toDelete(obj){
var modifyId=$(obj).parent().parent().find("input[type=checkbox]").attr("id");
	var confirmFlag= window.confirm("确认删除此记录？");
	if(confirmFlag){
		location.href="articleManage.do?pm=articleDelete&id="+modifyId;
		}
}
//删除所有标记的id
function deleteAll(){
	var deleteIds="";
	var deleteRecordcount=0;
	$(" #jdstudio_content_tr > [mvflagBycheck='true'] ").find(" input[type='checkbox'] ").each(function(){
		if($(this).attr("checked")){
			deleteIds+=$(this).attr('id')+",";
			deleteRecordcount++;
		}
	});
	if(deleteIds!=""){
		deleteIds=deleteIds.substring(0,deleteIds.length-1);
		var confirmFlag= window.confirm("确认删除"+deleteRecordcount+"笔记录？");
		if(confirmFlag){
		location.href="articleManage.do?pm=articleDelete&id="+deleteIds;
		}
	}else{
		alert("请选择记录！");
	}
}


</script>		
<script type="text/javascript">
/*******************分页查询模块JS*******************/
$(document).ready(function(){
var currentPage= $("#DispCurrentPage").html();
var maxPages= $("#DispMaxPages").html();
function toPageSearch(control){
	if(control=='first'){
		$("#CurrentPage").val("1");
	}else if(control=='prev'){
		$("#CurrentPage").val(parseInt(currentPage)-1);
	}else if(control=='next'){
		$("#CurrentPage").val(parseInt(currentPage)+1);
	}else if(control=='last'){
		$("#CurrentPage").val(maxPages);
	}else if(control=='goto'){
		if($("#Page_Goto").val()==''){
			alert("跳转页数为空！");
		}else{
			if(parseInt($("#Page_Goto").val())<1)
				$("#CurrentPage").val("1");
			else if(parseInt($("#Page_Goto").val())>parseInt(maxPages))
				$("#CurrentPage").val(maxPages);
			else 
				$("#CurrentPage").val($("#Page_Goto").val());
		}
	}
	var searchForm = document.getElementsByName("searchForm")[0];
	searchForm.action="articleManage.do?pm=gotoArticleList";
	searchForm.submit();
}
$("#Page_First").click(function(){toPageSearch("first")});
$("#Page_Prev").click(function(){toPageSearch("prev")});
$("#Page_Next").click(function(){toPageSearch("next")});
$("#Page_Last").click(function(){toPageSearch("last")});
$("#Page_Goto_Btn").click(function(){toPageSearch("goto")});
if(currentPage=="1"){
	$("#Page_First").unbind("click").hide();
	$("#Page_Prev").unbind("click").hide();
}
if(currentPage==maxPages){
	$("#Page_Next").unbind("click").hide();
	$("#Page_Last").unbind("click").hide();
}
$(".pagination").show();
})
/*******************分页查询模块JS_end*******************/
</script>	
				<div class="content-box-header">
					<h3>文章列表</h3>
					<div class="clear"></div>
				</div> <!-- End .content-box-header -->
				<div class="clear"></div>
				<div style="text-align: right;padding: 5px"><input style="border:solid 1px #CCC;width:100px;cursor:pointer" type="button" onmousemove=(this.style.background='#57a000') onmouseout=(this.style.background='#FFF') onclick="location.href='articleManage.do?pm=gotoArticleAdd'" value="新增"/>&nbsp;&nbsp;<input style="border:solid 1px #CCC;width:100px;cursor:pointer" onclick="deleteAll()" type="button" onmousemove=(this.style.background='#57a000') onmouseout=(this.style.background='#FFF') value="删除"/></div>
				<div class="clear"></div>
				<div>
					<div id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
					  <table>
							<thead>
								<tr class="content-box-head">
								   <th style="text-align:center;width: 2px"><input class="check-all" type="checkbox" /></th>
								   <th style="width:35%">文章名称</th>
								   <th style="width:20%">作者</th>
								   <th>类型</th>
								   <th>是否置顶</th>
								   <th>创建日期</th>
								   <th>点击数</th>
								   <th style="width: 4px">操作</th>
								</tr>
							</thead>
							<tbody id="jdstudio_content_tr">
								<tbody id="jdstudio_content_tr">
								<%
								if(lt.size()>0){
									for(int t=0;t<lt.size();t++){
								%>
									<tr mvflagBycheck="true">
									<td style="text-align:center;"><input type="checkbox" id="<%=lt.get(t).get("article_id")!=null?lt.get(t).get("article_id").toString():"" %>" /></td>
									<td><%=lt.get(t).get("article_name")!=null?lt.get(t).get("article_name").toString():"" %></td>
									<td><%=lt.get(t).get("article_writer")!=null?lt.get(t).get("article_writer").toString():"" %></td>
									<td><%=lt.get(t).get("article_type_name")!=null?lt.get(t).get("article_type_name").toString():"" %></td>
									<td><%=lt.get(t).get("article_position_top")!=null?(lt.get(t).get("article_position_top").toString().equals("1")?"是":"否"):"" %></td>
									<td><%=lt.get(t).get("article_create_date")!=null?lt.get(t).get("article_create_date").toString():"" %></td>
									<td><%=lt.get(t).get("article_click")!=null?lt.get(t).get("article_click").toString():"" %></td>
									<td>
										 <a onclick="toModify(this);" style="cursor:pointer" title="编辑"><img src="/resources/images/icons/pencil.png" alt="编辑" /></a>
										 <a onclick="toDelete(this);" style="cursor:pointer" title="删除"><img src="/resources/images/icons/cross.png" alt="删除"  /></a> 
									</td>
								</tr>
								<%}}else{ %>
								<%} %>
							</tbody>
								
								
							</tbody>
							<tfoot style="width:auto">
								<!-- 分页查询模块HTML -->
								<table>
										<div class="pagination" style="display:none">
											<a href="#">当前第<span id="DispCurrentPage">${queryMap.CurrentPage}</span>页&nbsp;共计<span id="DispMaxPages">${queryMap.MaxPages}</span>页&nbsp;总计${queryMap.MaxRecords}笔数据</a>
											<a id="Page_First" title="第一页" style="cursor:pointer;">&laquo; 第一页</a><a id="Page_Prev" title="上一页" style="cursor:pointer;">&laquo; 上一页</a>
											<a id="Page_Next" title="下一页" style="cursor:pointer;">下一页 &raquo;</a><a id="Page_Last" title="最后一页" style="cursor:pointer;">最后一页 &raquo;</a>
											<input id="Page_Goto" name="page" value="" size="4" maxlength="4" type="text" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}" /> <a id="Page_Goto_Btn" style="cursor:pointer;">跳转</a>
										</div>
										<div class="clear"></div>
								</table>
								<!-- 分页查询模块HTML END-->
							</tfoot>
						</table>
					</div> <!-- End #tab1 -->
				</div> <!-- End .content-box-content -->
				
</div>